#include <gui/dialpage_screen/DialPageView.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include "BitmapDatabase.hpp"
//标准库
#include <stdio.h>
#include <string.h>
//
DialPageView::DialPageView()
{

}
//
void DialPageView::setupScreen()
{
    DialPageViewBase::setupScreen();
}
//
void DialPageView::tearDownScreen()
{
    DialPageViewBase::tearDownScreen();
}
//更新时间
void DialPageView::updateTime(uint8_t newHours, uint8_t newMinutes, uint8_t newSeconds)
{
		digitalClock.setTime24Hour(newHours, newMinutes, newSeconds);
		analogClock.setTime24Hour(newHours,newMinutes,newSeconds);
}
//更新日期
void DialPageView::updateDate(uint8_t newYear, uint8_t newMonth, uint8_t newDate, uint8_t newWeekDay)
{
		Unicode::snprintf(textSystemYearBuffer, TEXTSYSTEMYEAR_SIZE, "%04d", newYear + 2000);
    textSystemYear.invalidate();	
		//
		Unicode::snprintf(textSystemDateBuffer1, TEXTSYSTEMDATEBUFFER1_SIZE, "%02d", newMonth);
		Unicode::snprintf(textSystemDateBuffer2, TEXTSYSTEMDATEBUFFER2_SIZE, "%02d", newDate);
	  textSystemDate.invalidate();
		//
		Unicode::snprintf(textWeekDayBuffer, TEXTWEEKDAY_SIZE, "%d", newWeekDay);
    textWeekDay.invalidate();
		//
		Unicode::snprintf(DateWindowBuffer, DATEWINDOW_SIZE, "%02d", newDate);
    DateWindow.invalidate();	
		//
}
//进入APP页面或快速设置界面
void DialPageView::DialPageChange(uint8_t newFiveKeyFunc)
{
		handleKeyEvent(newFiveKeyFunc);
}
//进入运动模式界面
void DialPageView::SportPageEnter(uint8_t newKeyFunc)
{
		handleKeyEvent(newKeyFunc);
}
//更新温度、步数、心率数据
void DialPageView::updateTempStepHeart(float newTem, unsigned long newStep, uint32_t newHeartRate)
{
		//更新温度-数字表盘
		Unicode::snprintfFloat(textTempBuffer, TEXTTEMP_SIZE, "%.1f",newTem);
	  textTemp.invalidate();
		//更新温度-模拟表盘
		Unicode::snprintfFloat(textTemp_anBuffer, TEXTTEMP_AN_SIZE, "%.1f",newTem);
	  textTemp_an.invalidate();
		//更新步数-数字表盘
		Unicode::snprintf(textStepBuffer, TEXTSTEP_SIZE, "%d",newStep);
	  textStep.invalidate();
		//更新步数-模拟表盘
		Unicode::snprintf(textStep_anBuffer, TEXTSTEP_AN_SIZE, "%d",newStep);
	  textStep_an.invalidate();
		//更新脉搏-数字表盘
		Unicode::snprintf(textPulseBuffer, TEXTPULSE_SIZE, "%d",newHeartRate);
	  textPulse.invalidate();
		//更新脉搏-模拟表盘
		Unicode::snprintf(textPulse_anBuffer, TEXTPULSE_AN_SIZE, "%d",newHeartRate);
	  textPulse_an.invalidate();	
}
